Skip to content

PDX-478: fix(mcp): parse .testproject connections and resolve env via associations#171

Merged
mrdailey99 merged 1 commit into
developfrom
fix/pdx-478-connection-parser
May 15, 2026
Merged

PDX-478: fix(mcp): parse .testproject connections and resolve env via associations#171
mrdailey99 merged 1 commit into
developfrom
fix/pdx-478-connection-parser

Conversation

@mrdailey99
Copy link
Copy Markdown
Collaborator

@mrdailey99 mrdailey99 commented May 15, 2026

Summary

Fixes both parser bugs in src/mcp/tools/connectionTools.ts that made provar_connection_list effectively non-functional on every real Provar project.

  • parseConnectionList now traverses connectionClass.connections.connection[] (the real XML shape) instead of connectionClass.connection[]
  • parseEnvironmentList now resolves the environment's connection by walking associations.association[].@connectionId and looking up the name from the connection ID map. Environment-specific URLs are matched by environment @guid against connectionUrl.@envId
  • Empty <associations></associations> (real-world edge case from TrialProject) is handled gracefully — returns connection: '' without crashing

Linked: PDX-478

Why this was missed

The existing test fixture used a flattened XML shape (<connectionClass><connection name=... url=.../></connectionClass> and <environment connectionName=... url=.../>) that did not exist in any real Provar .testproject file — but exactly matched the buggy parser code. The fixture has been rewritten to mirror the real XML produced by Provar Desktop, including the <connections> wrapper, <connectionUrls><connectionUrl @envId=.../> per-env URL list, and <associations><association @connectionId=.../> environment-to-connection link.

Impact (pre-fix baseline)

Surveyed 7 real Provar projects — every one returned 0 connections:

Project connectionClass / connection count connection_list returned
provar-manager-regression 6 / 12 0
Agentforce 4 / 16 0
ExperienceCloud 4 / 15 0
FinancialServices 2 / 9 0
PQP 5 / 11 0
ProvarDXGrid 2 / 2 0
TrialProject 2 / 2 0

Post-fix: every project returns its full connection list and environment-to-connection links resolve correctly.

Test plan

  • yarn compile clean
  • yarn lint clean
  • Full unit suite passes — 1109 passing, 0 failing (bypassed wireit cache)
  • node scripts/mcp-smoke.cjs54/54 PASS
  • Manual e2e verified across 7 real projects (see table above) — all return non-zero connection counts post-fix
  • Sub-field stripping from PDX-472 (fields=connections.name,connections.type) verified end-to-end on real data — previously vacuous due to empty connection arrays
  • Empty-<associations> edge case (TrialProject) handled without crash

Test coverage added

New assertions in test/unit/mcp/connectionTools.test.ts:

  • env→connection resolved via associations[@connectionId]
  • env-specific URL when connectionUrl.@envId matches env @guid
  • env URL omitted when no per-env URL exists
  • empty <associations> returns connection: '' without crashing
  • connection url uses default connectionUrl (entry without @envId)

🤖 Generated with Claude Code

… associations

RCA: provar_connection_list returned 0 connections on every real Provar project (surveyed 7) because parseConnectionList traversed connectionClass.connection[] but the actual .testproject XML nests each <connection> under a <connections> wrapper. parseEnvironmentList separately read @connectionName and @url attributes that do not exist on <environment> elements — the connection link is in <associations><association connectionId="..."/></associations>, keyed to the connection's @id, and per-env URLs live on the matching connection's <connectionUrl @envid="<env.@Guid>"/> entry. The existing test fixture used the flattened (broken) XML shape that the buggy code expected, so CI never caught either bug.

Fix: Traverse connectionClass.connections.connection[]. Build a connection-id-to-info map containing the default URL (the connectionUrl with no @envid) and a map of envId-to-URL overrides. Resolve environment.connection by mapping associations.association[0].@connectionId back to the connection name via that map, and use the env-specific URL when env.@Guid matches a connectionUrl.@envid. Handle empty <associations> (string-empty per real Provar XML) gracefully. Replace the fixture to mirror real .testproject XML and add tests for env→connection resolution, env-specific URL via @Guid, default-URL selection, and empty-associations. Verified non-zero connection counts and correct env→connection resolution across 7 real projects (provar-manager-regression, Agentforce, ExperienceCloud, FinancialServices, PQP, ProvarDXGrid, TrialProject). All 1109 unit tests pass; 54 smoke responses pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 15, 2026 11:52
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 15, 2026

Quality Orchestrator

🟢 LOW · 2 / 100 · All changed files have mapped tests.


🧪 Tests to Run · Running 1 of 50 tests

  • unit/mcp/connectionTools.test.ts
▶ Run command
npx vitest run \
  unit/mcp/connectionTools.test.ts

⚡ quality-orchestrator  ·  /qo stub <file>  ·  qo analyze-local

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes .testproject parsing for provar_connection_list so it matches real Provar project XML structure and correctly resolves environment-to-connection associations.

Changes:

  • Parses connections from connectionClass.connections.connection[] with default and environment-specific connectionUrl entries.
  • Resolves environment connections through associations.association[].connectionId.
  • Updates unit fixtures and assertions to cover real XML shape and empty associations.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/mcp/tools/connectionTools.ts Updates connection and environment parsing logic for real .testproject XML.
test/unit/mcp/connectionTools.test.ts Replaces flattened fixture with realistic XML and adds regression coverage for environment URL/association behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mrdailey99 mrdailey99 merged commit cfd309d into develop May 15, 2026
12 checks passed
@mrdailey99 mrdailey99 deleted the fix/pdx-478-connection-parser branch May 15, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants